<?php
//+--------------------------------------------
//|描述
//|--------------------------------------------
//|Created by PhpStorm.
//| Author: DRG
//+-------------------------------------------
//|Date: 2018/6/5
//| Time: 11:09
//+--------------------------------------------
namespace app\index\controller;

use app\common\lib\Predis;
use app\common\lib\Redis;
use app\common\lib\Util;

class Chat {
    
    public function index()
    {
        //登录判断
        if (empty($_POST)) {
            return Util::show(config('code.codeError'), 'input error');
        }
        //print_r($_POST['SWOOLE_HTTP_SERVER']->ports);
        $data =  [
            'method'        => 'pushChat',
            'data'          => [
                'userName'  => 'test_'.rand(1,9),
                'content'   => $_POST['content']
            ]
        ];
        foreach ($_POST['SWOOLE_HTTP_SERVER'] -> ports[1]->connections as $fd) {
//            print_r($fd);
        }
//        $_POST['SWOOLE_HTTP_SERVER'] -> task($data);
        return Util::show(config('code.success'), 'send ok');
        
    }
    
}